package cn.itrip.auth.service;

import org.springframework.mail.MailMessage;
import org.springframework.mail.MailSender;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author 瑾
 */
@Service("mailService")
public class MailServiceImpl implements  MailService {

    @Resource(name = "mailMessage")
    private SimpleMailMessage mailMessage;

    @Resource(name = "mailSender")
    private MailSender mailSender;

    /**
     * 发送邮件到某个人
     * @param sendto   发送的人
     * @param activeCode  激活码
     */
    @Override
    public void sendActiveMail(String sendto, String activeCode) {

        mailMessage.setTo(sendto);
        /*
        设置正文内容
         */
//        mailMessage.setText("----罗锦洪，狗东西，请你吗的假，赶紧回学校嗨-----");
        mailMessage.setText("您的激活码是："+activeCode);
        mailSender.send(mailMessage);


    }
}
